package com.seres.general;
//import TestListener;

import java.util.ArrayList;
import java.util.List;

import com.seres.events.AcesInfoEvent;
import com.seres.events.AcronymsInfoEvent;
import com.seres.events.AiInfoEvent;
import com.seres.events.DecisionEvent;
import com.seres.events.GameStateEvent;
import com.seres.events.MainMessageEvent;
import com.seres.events.MessageInfoEvent;
import com.seres.events.ModuleInfoEvent;
import com.seres.events.ScenarioInfoEvent;
import com.seres.events.StatusOverviewEvent;
import com.seres.listeners.AcesInfoListener;
import com.seres.listeners.AcronymsInfoListener;
import com.seres.listeners.AiInfoListener;
import com.seres.listeners.DecisionListener;
import com.seres.listeners.GameStateListener;
import com.seres.listeners.MainMessageListener;
import com.seres.listeners.MessageInfoListener;
import com.seres.listeners.ModuleInfoListener;
import com.seres.listeners.ScenarioInfoListener;
import com.seres.listeners.StatusOverviewListener;



public class EventBroker {
	private static EventBroker eventBroker;
	
	private List<AcesInfoListener> acesInfoListeners;
	private List<DecisionListener> decisionListeners;
	private List<GameStateListener> gameStateListeners;
	private List<ModuleInfoListener> moduleInfoListeners;
	private List<ScenarioInfoListener> scenarioInfoListeners;
	private List<MessageInfoListener> messageInfoListeners;
	private List<StatusOverviewListener> statusOverviewListeners;
	private List<MainMessageListener> mainMessageListeners;
	private List<AcronymsInfoListener> acronymsInfoListeners;
	private List<AiInfoListener> aiInfoListeners;
	
	private EventBroker(){
		acesInfoListeners = new ArrayList<AcesInfoListener>();
		decisionListeners = new ArrayList<DecisionListener>();
		gameStateListeners = new ArrayList<GameStateListener>();
		moduleInfoListeners = new ArrayList<ModuleInfoListener>();
		scenarioInfoListeners = new ArrayList<ScenarioInfoListener>();
		messageInfoListeners = new ArrayList<MessageInfoListener>();
		statusOverviewListeners = new ArrayList<StatusOverviewListener>();
		mainMessageListeners = new ArrayList<MainMessageListener>();
		acronymsInfoListeners = new ArrayList<AcronymsInfoListener>();
		aiInfoListeners = new ArrayList<AiInfoListener>();
	}
	
	public static void main(String[] args){
		
//		TestListener testListener = new TestListener();
//		
//		List<AceCategory> list = new ArrayList<AceCategory>();
//		list.add(new AceCategory("cat1", null));
//		list.add(new AceCategory("cat2", null));
//		AcesInfoEvent event = new AcesInfoEvent(list);
//		eventBroker.fireAcesInfoEvent(event);
//		
	}
	
	public static EventBroker getEventBroker(){
		if(eventBroker == null){
			eventBroker = new EventBroker();
		}
		return eventBroker;
	}
	
	public void addAcesInfoListener(AcesInfoListener listener){
		acesInfoListeners.add(listener);
	}
	public void removeAcesInfoListener(AcesInfoListener listener){
		acesInfoListeners.remove(listener);
	}
	public void addDecisionListener(DecisionListener listener){
		decisionListeners.add(listener);
	}
	public void removeDecisionListener(DecisionListener listener){
		decisionListeners.remove(listener);
	}
	public void addGameStateListener(GameStateListener listener){
		gameStateListeners.add(listener);
	}
	public void removeGameStateListener(GameStateListener listener){
		gameStateListeners.remove(listener);
	}
	public void addModuleInfoListener(ModuleInfoListener listener){
		moduleInfoListeners.add(listener);
	}
	public void removeModuleInfoListener(ModuleInfoListener listener){
		moduleInfoListeners.remove(listener);
	}
	public void addScenarioInfoListener(ScenarioInfoListener listener){
		scenarioInfoListeners.add(listener);
	}
	public void removeScenarioInfoListener(ScenarioInfoListener listener){
		scenarioInfoListeners.remove(listener);
	}
	public void addMessageInfoListener(MessageInfoListener listener){
		messageInfoListeners.add(listener);
	}
	public void removeMessageInfoListener(MessageInfoListener listener){
		messageInfoListeners.remove(listener);
	}
	public void addStatusOverviewListener(StatusOverviewListener listener){
		statusOverviewListeners.add(listener);
	}
	public void removeStatusOverviewListener(StatusOverviewListener listener){
		statusOverviewListeners.remove(listener);
	}
	public void addMainMessageListener(MainMessageListener listener){
		mainMessageListeners.add(listener);
	}
	public void removeMainMessageListener(MainMessageListener listener){
		mainMessageListeners.remove(listener);
	}
	public void addAcronymsInfoListener(AcronymsInfoListener listener){
		acronymsInfoListeners.add(listener);
	}
	public void removeAcronymsInfoListener(AcronymsInfoListener listener){
		acronymsInfoListeners.remove(listener);
	}
	public void addAiInfoListener(AiInfoListener listener){
		aiInfoListeners.add(listener);
	}
	public void removeAiInfoListener(AiInfoListener listener){
		aiInfoListeners.remove(listener);
	}
	
	public void fireAcesInfoEvent(AcesInfoEvent event){
		for(AcesInfoListener listener: acesInfoListeners){
			listener.processAcesInfo(event);
		}
	}
	public void fireDecisionEvent(DecisionEvent event){
		for(DecisionListener listener: decisionListeners){
			listener.processDecision(event);
		}
	}
	public void fireGameStateEvent(GameStateEvent event){
		for(GameStateListener listener: gameStateListeners){
			listener.processGameState(event);
		}
	}
	public void fireModuleInfoEvent(ModuleInfoEvent event){
		for(ModuleInfoListener listener: moduleInfoListeners){
			listener.processModuleInfo(event);
		}
	}
	public void fireScenarioInfoEvent(ScenarioInfoEvent event){
		for(ScenarioInfoListener listener: scenarioInfoListeners){
			listener.processScenarioInfo(event);
		}
	}
	public void fireMessageInfoEvent(MessageInfoEvent event){
		for(MessageInfoListener listener: messageInfoListeners){
			listener.processMessageInfo(event);
		}
	}
	public void fireStatusOverviewEvent(StatusOverviewEvent event){
		for(StatusOverviewListener listener: statusOverviewListeners){
			listener.processStatusOverview(event);
		}
	}
	public void fireMainMessageEvent(MainMessageEvent event){
		for(MainMessageListener listener: mainMessageListeners){
			listener.processMainMessage(event);
		}
	}
	public void fireAcronymsInfoEvent(AcronymsInfoEvent event){
		for(AcronymsInfoListener listener: acronymsInfoListeners){
			listener.processAcronymsInfo(event);
		}
	}
	public void fireAiInfoEvent(AiInfoEvent event){
		for(AiInfoListener listener: aiInfoListeners){
			listener.processAiInfo(event);
		}
	}
}
